package pl.lodz.p.browarex.mvc;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import pl.lodz.p.browarex.model.OrderProductInfo;
import pl.lodz.p.browarex.services.interfaces.IProductService;

@Controller
public class ManufactureController {
	
	@Inject
	IProductService productService;
	
	@RequestMapping(value = "/manufacturer", method = RequestMethod.GET)
	public String showManufactureBeer(
			@RequestParam("name") String manufacturer, Model model)
			throws Exception {
		
		model.addAttribute("orderProductInfo", new OrderProductInfo());
		model.addAttribute("manufacturerProduct",
				productService.findProductByManufacturer(manufacturer));
		
		return "manufacturer";
	}

}
